/******************************************************************************
*  COPYRIGHT MorningCore CO.,LTD
******************************************************************************/

/*****************************************************************
 * FileName::    ZCRootSeqGen.c
 * version::     1.0.0
 * Purpose:      Zadoff-Chu root sequence generation
 * Authors:      zhangshanzhong, 2008-12-18
 * Notes:        None
 ******************************************************************/

/******************************************************************************
*  HISTORY OF CHANGES
*   <Date>          <Author>        <Version>       <DESCRIPTION>
*   2008-12-18      zhangshanzhong  V1.0.0           original
******************************************************************************/

/******************************************************************************
*  INCLUDE FILES
******************************************************************************/
#include <stdio.h>
#include <math.h>
#include "ZCRootSeqGen.h"

/*----------- function definition-----------------------------------*/
/*****************************************************************************
* Function: ZCRootSeqGen()
* Purpose:  This function performs Zadoff-Chu root sequence generation for base
*           sequence generation for RS and preamble sequence for PRACH.
*
* Relation:
            Calls       : RotateCoefGen()
            Called by   : ...
* Params:
*   <Name>                  <Type>      <In/Out>    <Description>
*   RootSeqLen              int         In          Root sequence length
*   RootSeqParam            int         In          Sequence index
*   N_RotateCoef            int8        In          processing bit width
*   ZCRootSeqGen_Op[1320]   cmplx_frN   Out         Output ZC root sequence Q(16,1)
* Return:  void
* Note:    <the limitations to use this function or other comments>
*******************************************************************************/
void ZCRootSeqGen
(
    stULParamTable *SimParam,
    cmplx_t   ZCRootSeqGen_Op[839] // Zadoff-Chu root sequence
)
{
    /*variables definition*/
    int i; // loop index
    uint32 DividParam; // input dividend parameter //modified by shanshan 20100624
    int16 divisor;  // divisor of input
    cmplx_t temp; //

    /*Init*/

    // root sequence length as divisor
    divisor = SimParam->L_RA;

    /*Function body*/
    for (i = 0; i < SimParam->L_RA; i++)
    {
        DividParam = SimParam->PRACH_ZC_u * i * (i + 1);
        temp.re = (double)cos(3.1415926 * DividParam / SimParam->L_RA);
        temp.im = - (double)sin(3.1415926 * DividParam / SimParam->L_RA);
        // write to output
        ZCRootSeqGen_Op[i] = temp;
    }
}




